import { gen, resolveBaseChartScopeSlot } from './core'
const Plot = { gen }

export default Plot

export function registerBusinessComponent(options) {
    options.forEach(function (plotDef) {
        Vue.component(plotDef.name, plotDef)
    })
}

// 解析组件配置
export function resolveOption(vm, extOpt) {
    extOpt = extOpt || {}
    const data = {
        props: {
            ...(extOpt.props || {}),
            ...(vm.$attrs),
        },
        attrs: {
            ...(extOpt.props || {}),
            ...(vm.$attrs),

        },
        scopedSlots: extOpt.scopedSlots || resolveBaseChartScopeSlot(vm.$scopedSlots),
        on: extOpt.on || vm.$listeners,
        'class': extOpt['class'],
        'style': extOpt['style'],
        'ref': extOpt['ref'],
        'domProps': extOpt['domProps'],
        'nativeOn': extOpt['nativeOn'],
        'directives': extOpt['directives'],
        'slot': extOpt['slot'],
        'key': extOpt['key']
    }
    const slots = vm.$slots
    return {
        data, slots
    }
}
